namespace ClassyBlog.Web
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.WebPages;

    using ExtensionMethods;

    public static class WebViewHelper
    {
        public static HelperResult RenderEach<TItem>(
            this IEnumerable<TItem> items, Func<TItem, HelperResult> template)
        {
            return items == null ?
                   null :
                   new HelperResult(writer =>
                       items.Select(template).Each(result =>
                           result.WriteTo(writer)));
        }
    }
}